﻿<navigation:Page x:Class="LEEAAttendanceControl.Views.EmployeesView"
           xmlns:vc="clr-namespace:LEEAAttendanceControl.Codes"
           xmlns:toolkit="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit"
           xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk"
           xmlns:riaControls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.DomainServices"
           xmlns:my="clr-namespace:LEEAAttendanceControl.Web.Services"
           xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
           xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
           xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
           xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
           mc:Ignorable="d"
           xmlns:navigation="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Navigation"
           d:DesignWidth="640" d:DesignHeight="480"
           Title="Employees View">
    <Grid x:Name="LayoutRoot">
        <Grid.Resources>
            <sdk:HierarchicalDataTemplate x:Key="EmployeeTemplate">
                <StackPanel Orientation="Horizontal">
                    <Ellipse Fill="{Binding Color}" Stroke="{Binding Color}" Height="8" Width="8" Margin="0,0,5,0"/>
                    <TextBlock Text="{Binding Name}"/>
                </StackPanel>
            </sdk:HierarchicalDataTemplate>
            <sdk:HierarchicalDataTemplate x:Key="DepartmentTemplate" ItemTemplate="{StaticResource EmployeeTemplate}"
                                          ItemsSource="{Binding Nodes}">
                <TextBlock Text="{Binding Name}"/>
            </sdk:HierarchicalDataTemplate>
            <sdk:HierarchicalDataTemplate x:Key="CompanyTemplate" ItemsSource="{Binding Nodes}"
                                          ItemTemplate="{StaticResource DepartmentTemplate}">
                <TextBlock Text="{Binding Name}"/>
            </sdk:HierarchicalDataTemplate>

            <vc:MinutesToHoursConverter x:Key="MinutesToHoursConverter"/>
        </Grid.Resources>
        
        <Grid.RowDefinitions>
            <RowDefinition Height="65"/>
            <RowDefinition/>
            <RowDefinition Height="65"/>
        </Grid.RowDefinitions>
        
        <Grid Grid.Row="0" Grid.RowSpan="3">
            <ScrollViewer VerticalScrollBarVisibility="Auto">
                <Grid>
                    <Grid Height="35" Background="Black" VerticalAlignment="Top">
                        <Ellipse Fill="White" Width="30" Height="30" Margin="5,0,0,0" HorizontalAlignment="Left"/>
                        <Image Source="/LEEAAttendanceControl;component/Images/Time.png" Width="30" Height="30"
                               Margin="5,0,0,0" HorizontalAlignment="Left"/>

                        <TextBlock Text="LEEA Time Control" FontSize="17" Foreground="White" FontWeight="Bold" Margin="45,5,0,0"/>

                        <Border HorizontalAlignment="Right" BorderBrush="White" BorderThickness="1" Margin="2,2,6,2">
                            <StackPanel Orientation="Horizontal">
                                <TextBlock x:Name="welcomeText" Foreground="White" FontSize="12" VerticalAlignment="Center"
                                           Text="Welcome: Fathi" Margin="10,0,15,0"/>
                                <Rectangle Width="1" Fill="White" Height="20"/>
                                <HyperlinkButton x:Name="hyperLogout" Content="Logout" FontSize="12" Margin="15,0,10,0"
                                                 VerticalAlignment="Center" Click="hyperLogout_Click" BorderBrush="Azure"
                                                 BorderThickness="2" Foreground="Aqua"/>
                            </StackPanel>
                        </Border>
                    </Grid>

                    <Grid Background="#005f8f" Margin="0,35,0,0">
                        <StackPanel Orientation="Vertical" Grid.Row="0">
                            <Grid Background="#005f8f">
                                <TextBlock x:Name="SummaryBlock" Text="Summary" FontSize="14" Foreground="White"
                                           FontWeight="Bold" Margin="5,3,3,2"/>
                            </Grid>
                            
                            <riaControls:DomainDataSource x:Name="HoursSummaryDataSource" AutoLoad="True"
                                                  QueryName="GetHoursSummaries"
                                                  LoadingData="HoursSummaryDataSource_LoadingData">
                                <riaControls:DomainDataSource.DomainContext>
                                    <my:LEEAContext />
                                </riaControls:DomainDataSource.DomainContext>
                            </riaControls:DomainDataSource>

                            <sdk:DataGrid x:Name="SummaryGrid" AutoGenerateColumns="False" IsReadOnly="True"
                                  ItemsSource="{Binding Data, ElementName=HoursSummaryDataSource}">
                                <sdk:DataGrid.Columns>
                                    <sdk:DataGridTemplateColumn Header="Total" Width="254" IsReadOnly="True" CanUserReorder="False"
                                                        CanUserResize="False" CanUserSort="True">
                                        <sdk:DataGridTemplateColumn.CellTemplate>
                                            <DataTemplate>
                                                <sdk:Label Content="{Binding Total, Converter={StaticResource MinutesToHoursConverter}}"
                                                   Margin="5,0,0,0" VerticalAlignment="Center" HorizontalAlignment="Left"
                                                   Height="25"/>
                                            </DataTemplate>
                                        </sdk:DataGridTemplateColumn.CellTemplate>
                                    </sdk:DataGridTemplateColumn>
                                    <sdk:DataGridTemplateColumn Header="Breaks" Width="254" IsReadOnly="True" CanUserReorder="False"
                                                        CanUserResize="False" CanUserSort="True">
                                        <sdk:DataGridTemplateColumn.CellTemplate>
                                            <DataTemplate>
                                                <sdk:Label Content="{Binding Breaks, Converter={StaticResource MinutesToHoursConverter}}"
                                                   Margin="5,0,0,0" VerticalAlignment="Center" HorizontalAlignment="Left"
                                                   Height="25"/>
                                            </DataTemplate>
                                        </sdk:DataGridTemplateColumn.CellTemplate>
                                    </sdk:DataGridTemplateColumn>
                                    <sdk:DataGridTemplateColumn Header="Exceptions" Width="253" IsReadOnly="True" CanUserReorder="False"
                                                        CanUserResize="False" CanUserSort="True">
                                        <sdk:DataGridTemplateColumn.CellTemplate>
                                            <DataTemplate>
                                                <sdk:Label Content="{Binding Exceptions, Converter={StaticResource MinutesToHoursConverter}}"
                                                   Margin="5,0,0,0" VerticalAlignment="Center" HorizontalAlignment="Left"
                                                   Height="25"/>
                                            </DataTemplate>
                                        </sdk:DataGridTemplateColumn.CellTemplate>
                                    </sdk:DataGridTemplateColumn>
                                    <sdk:DataGridTemplateColumn Header="Paid" Width="253" IsReadOnly="True" CanUserReorder="False"
                                                        CanUserResize="False" CanUserSort="True">
                                        <sdk:DataGridTemplateColumn.CellTemplate>
                                            <DataTemplate>
                                                <sdk:Label Content="{Binding Paid, Converter={StaticResource MinutesToHoursConverter}}"
                                                   Margin="5,0,0,0" VerticalAlignment="Center" HorizontalAlignment="Left"
                                                   Height="25"/>
                                            </DataTemplate>
                                        </sdk:DataGridTemplateColumn.CellTemplate>
                                    </sdk:DataGridTemplateColumn>
                                    <sdk:DataGridTemplateColumn Header="Overtime" Width="248" IsReadOnly="True" CanUserReorder="False"
                                                        CanUserResize="False" CanUserSort="True">
                                        <sdk:DataGridTemplateColumn.CellTemplate>
                                            <DataTemplate>
                                                <sdk:Label Content="{Binding Overtime, Converter={StaticResource MinutesToHoursConverter}}"
                                                   Margin="5,0,0,0" VerticalAlignment="Center" HorizontalAlignment="Left"
                                                   Height="25"/>
                                            </DataTemplate>
                                        </sdk:DataGridTemplateColumn.CellTemplate>
                                    </sdk:DataGridTemplateColumn>
                                </sdk:DataGrid.Columns>
                            </sdk:DataGrid>
                        </StackPanel>
                    </Grid>

                    <Grid Background="White" Margin="0,135,0,0" ShowGridLines="False">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="225"/>
                            <ColumnDefinition/>
                            <ColumnDefinition Width="220"/>
                        </Grid.ColumnDefinitions>

                        <Border Grid.Column="0" BorderBrush="Black" BorderThickness="1">
                            <toolkit:Accordion x:Name="taskDion" toolkit:DockPanel.Dock="Top" SelectionMode="ZeroOrOne"
                                       Width="215" Margin="4" Grid.Row="0" Loaded="taskDion_Loaded">
                                <toolkit:AccordionItem x:Name="EmpHoursItem" Header="Employee Hours" FontSize="12"
                                                       Selected="EmpHoursItem_Selected">
                                    <Grid Width="210">
                                        <Canvas Height="60">
                                            <HyperlinkButton x:Name="EmpPunchLink" Canvas.Left="25" Canvas.Top="10"
                                                             Content="Employee Punches" TargetName="mainFrame"
                                                             NavigateUri="/Views/SpecificHours.xaml"/>
                                            <HyperlinkButton x:Name="OverTimeLink" Canvas.Left="25" Canvas.Top="35"
                                                             Content="Employee Overtime" TargetName="mainFrame"
                                                             NavigateUri="/Views/SpecificOvertime.xaml"/>
                                        </Canvas>
                                    </Grid>
                                </toolkit:AccordionItem>
                                <toolkit:AccordionItem x:Name="ReportsItem" Header="Reports" FontSize="12"
                                                       Selected="ReportsItem_Selected">
                                    <Grid Width="210">
                                        <ScrollViewer VerticalScrollBarVisibility="Visible" HorizontalScrollBarVisibility="Disabled">
                                            <Canvas Height="235">
                                                <HyperlinkButton x:Name="SummaryCardRepLink" Canvas.Left="20" Canvas.Top="10"
                                                         Content="Summary Time Card" Click="SummaryCardRepLink_Click"/>
                                                <HyperlinkButton x:Name="DetailedCardRepLink" Canvas.Left="20" Canvas.Top="35"
                                                         Content="Detailed Time Card" Click="DetailedCardRepLink_Click"/>
                                                <HyperlinkButton x:Name="DetailedOvertimeRepLink" Canvas.Left="20" Canvas.Top="60"
                                                         Content="Detailed Overtime" Click="DetailedOvertimeRepLink_Click"/>
                                                <HyperlinkButton x:Name="ShiftAssignmentRepLink" Canvas.Left="20" Canvas.Top="85"
                                                         Content="Shift Assignments" Click="ShiftAssignmentRepLink_Click"/>
                                                <HyperlinkButton x:Name="ExAssignmentRepLink" Canvas.Left="20" Canvas.Top="110"
                                                         Content="Exception Assignments" Click="ExAssignmentRepLink_Click"/>
                                                <HyperlinkButton x:Name="LateComerRepLink" Canvas.Left="20" Canvas.Top="135"
                                                         Content="Late Comers" Click="LateComerRepLink_Click"/>
                                                <HyperlinkButton x:Name="AbsenceRepLink" Canvas.Left="20" Canvas.Top="160"
                                                         Content="Absence" Click="AbsenceRepLink_Click"/>
                                                <HyperlinkButton x:Name="SavedHoursRepLink" Canvas.Left="20" Canvas.Top="185"
                                                         Content="Saved Hours" Click="SavedHoursRepLink_Click"/>
                                                <HyperlinkButton x:Name="MissingPunchRepLink" Canvas.Left="20" Canvas.Top="210"
                                                         Content="Missing Punches" Click="MissingPunchRepLink_Click"/>
                                            </Canvas>
                                        </ScrollViewer>
                                    </Grid>
                                </toolkit:AccordionItem>
                                <toolkit:AccordionItem x:Name="StructureItem" Header="Structure Details" FontSize="12"
                                                       Selected="StructureItem_Selected">
                                    <Grid Width="210">
                                        <Canvas Height="65">
                                            <HyperlinkButton x:Name="ComDetailsLink" Content="Company Details" Canvas.Left="25"
                                                             Canvas.Top="10" TargetName="mainFrame"
                                                             NavigateUri="/Views/SpecificCompany.xaml"/>
                                            <HyperlinkButton x:Name="EmpDetailsLink" Content="Employee Details" Canvas.Left="25"
                                                             Canvas.Top="35" TargetName="mainFrame"
                                                             NavigateUri="/Views/SpecificDetails.xaml"/>
                                        </Canvas>
                                    </Grid>
                                </toolkit:AccordionItem>
                                <toolkit:AccordionItem x:Name="ShiftsItem" Header="Shifts" FontSize="12"
                                                       Selected="ShiftsItem_Selected">
                                    <Grid Width="210">
                                        <Canvas Height="65">
                                            <HyperlinkButton x:Name="ShiftsLink" Content="Shifts" Canvas.Left="25"
                                                             Canvas.Top="10" TargetName="mainFrame"
                                                             NavigateUri="/Views/SpecificShifts.xaml"/>
                                            <HyperlinkButton x:Name="ShitAssignmentsLink" Content="Shift Assignments"
                                                             Canvas.Left="25" Canvas.Top="35" TargetName="mainFrame"
                                                             NavigateUri="/Views/SpecificShiftsAssignments.xaml"/>
                                        </Canvas>
                                    </Grid>
                                </toolkit:AccordionItem>
                                <toolkit:AccordionItem x:Name="ExceptionsItem" Header="Exceptions" FontSize="12"
                                                       Selected="ExceptionsItem_Selected">
                                    <Grid Width="210">
                                        <Canvas Height="65">
                                            <HyperlinkButton x:Name="ExceptionsLink" Content="Exceptions" Canvas.Left="25"
                                                             Canvas.Top="10" TargetName="mainFrame"
                                                             NavigateUri="/Views/SpecificExceptions.xaml"/>
                                            <HyperlinkButton x:Name="ExAssignmentsLink" Content="Exception Assignments"
                                                             Canvas.Left="25" Canvas.Top="35" TargetName="mainFrame"
                                                             NavigateUri="/Views/SpecificExceptionsAssignments.xaml"/>
                                        </Canvas>
                                    </Grid>
                                </toolkit:AccordionItem>
                            </toolkit:Accordion>
                        </Border>

                        <Border BorderBrush="Black" BorderThickness="1" Grid.Column="1">
                            <Grid>
                                <sdk:Frame x:Name="mainFrame"/>
                            </Grid>
                        </Border>

                        <Border BorderBrush="Black" BorderThickness="1" Grid.Column="2">
                            <Grid>
                                <Grid.RowDefinitions>
                                    <RowDefinition/>
                                    <RowDefinition Height="150"/>
                                </Grid.RowDefinitions>

                                <sdk:TreeView x:Name="structureTree" BorderBrush="Black" BorderThickness="1" Grid.Row="0"
                                              Margin="5" ItemTemplate="{StaticResource CompanyTemplate}"
                                              Loaded="structureTree_Loaded"/>

                                <StackPanel Orientation="Vertical" Grid.Row="1">
                                    <Grid Background="#404041" Height="30">
                                        <TextBlock Text="Accounting Period" FontFamily="Verdana" FontSize="14" FontWeight="Bold"
                                                   VerticalAlignment="Center" Margin="5,0,0,0" Foreground="White"/>
                                    </Grid>

                                    <Grid Height="20"/>

                                    <Canvas>
                                        <TextBlock Text="From: " FontSize="12" Canvas.Left="3" Canvas.Top="5"/>
                                        <sdk:DatePicker x:Name="PeriodFrom" Width="165" Canvas.Left="43" Canvas.Top="0"/>

                                        <TextBlock Text="To: " FontSize="12" Canvas.Left="3" Canvas.Top="35"/>
                                        <sdk:DatePicker x:Name="PeriodTo" Width="165" Canvas.Left="43" Canvas.Top="30"/>

                                        <Button x:Name="applyPeriodButton" Content="Apply" Width="65" Canvas.Left="141"
                                                Canvas.Top="65" Click="applyPeriodButton_Click"/>
                                    </Canvas>
                                </StackPanel>
                            </Grid>
                        </Border>
                    </Grid>
                </Grid>
            </ScrollViewer>
        </Grid>
    </Grid>
</navigation:Page>
